package com.crocodileQ.utils;

import com.alibaba.fastjson.JSON;
import com.crocodileQ.common.R;
import com.crocodileQ.enums.AppExceptionMsgEnum;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class WebUtil {

    /**
     * 将字符串渲染到客户端
     */
    public static void renderString(HttpServletResponse response, AppExceptionMsgEnum appMsg){
        response.setStatus(200);
        response.setContentType("application/json");
        response.setCharacterEncoding("utf-8");
        String s = JSON.toJSONString(R.error(appMsg));

        try {
            response.getWriter().print(s);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }



}
